class UserController {

   // def index = { }
    def scaffold = User
    def login = {}

    def handleLogin =
    {
        println "strat"
        def user = User.findByUserName(params.userName)
        if(!user)
        {
            flash.message = "Brak wpisu dla: ${params.userName}"
            redirect(action:'login')

        }
        flash.message = "Znaleziono: ${params.userName}"
        session.user = user
        redirect(controller:'todo')
    }


    /*
    def handleLogin =
    {
        redirect(controller:'todo')
    }
    */

    def gotoTodo =
    {
        redirect(controller:'todo')
    }

    def logout =
    {
        if(session.user)
        {
            session.user = null
            redirect(action:'login')
        }
    }
}
